<?php

namespace app\common\model\mysql;

use think\Model;

class SGoodsVisitors extends Model
{

    /**
     * @var mixed
     */
    private $id;

    /**
     * 添加商品访客数登记管理
     * @param $data
     * @return mixed
     */
    public function addGoodsVisitors($data){
        $this->save($data);
        return $this->id;
    }

    /**
     * 查找数据库是否存在此条记录
     * @param $goodsId
     * @param $visitorsIp
     * @return SGoodsVisitors|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getGoodsVisitorsData($goodsId,$visitorsIp){
        $where = [
            ['visitors_ip', '=', $visitorsIp],
            ['goods_id', '=', $goodsId]
        ];
        $result = $this->where($where)->find();
        return $result;
    }
}
